<template>
	<view class="agreement-container">
		<rich-text :nodes="agreement"></rich-text>
		<view class="bottom-box d-flex justify-content-between">
			<button class="refuse" @click="handleRefuse" text=""> 拒绝</button>
			<button @click="handleJump" :style="countDown==0?'background-color: rgba(83, 179, 217, 1);':''"
				class="agree">{{text}}</button>
		</view>
	</view>
	</view>
</template>

<script>
	import parse from 'mini-html-parser2';
	export default {
		data() {
			return {
				countDown: 5,
				tiemr: '',
				text: '5s后同意',
				agreement: '湖北众华国民遗嘱库有限公司是从事遗嘱管理服务的专业机构，遗嘱人或登记人在本公司登记的遗嘱及其材料，本公司不对遗嘱及其材料的真实性、合法性和有效性进行实质性审查。我公司作为遗嘱登记机构，只能证明登记人或者遗嘱人在本公司登记并保存了遗嘱，对遗嘱的真实性、合法性和有效性，不承担法律责任。尽管如此，遗嘱人在此登记遗嘱后，就成为遗嘱库的会员，请遗嘱人或登记人在遗嘱登记后三十日内将纸质遗嘱资料等相关材料，邮寄给遗嘱库，并在每半年时间内交纳五十元的会员费，遗嘱人按规定享受会员权利并承担义务。遗嘱库的联系电话400-995-0717。  ',
				path: ''
			};
		},
		watch: {
			countDown() {
				if (this.countDown == 0) {
					clearInterval(this.tiemr)
					this.text = '同意'
				}
			}
		},
		onLoad(e) {
			this.tz(e)

			this.tiemr = setInterval(() => {
				this.countDown--
				this.text = this.countDown + 's后同意'
			}, 1000)
			parse(this.agreement, (err, nodes) => {
				if (!err) {
					this.agreement = nodes
				}
			})
		},
		methods: {
			tz(e) {
				if (e.type == 0) {
					this.path = '/pages/index/will/register'
				}
				if (e.type == 10) {
					this.path = '/pages/my/cooperationUnit'
				}
				if (e.type == 11) {
					this.path = '/pages/my/cooperationPersonal'
				}
			},
			handleRefuse() {
				uni.navigateBack({
					delta: 1
				})
			},
			handleJump() { //页面跳转
				if (this.countDown == 0) {
					uni.navigateTo({
						url: this.path
					})
				}

			}
		}
	}
</script>

<style lang="scss">
	.agreement-container {
		line-height: 1;

		.bottom-box {
			position: fixed;
			bottom: 50rpx;
			left: 0;
			right: 0;
			margin: 0 20rpx;

			.refuse {
				width: 340rpx;
				height: 88rpx;
				border: 1rpx solid #53B3D9;
				border-radius: 44rpx;
				font-size: 30rpx;
				font-weight: 500;
				color: #53B3D9;
				line-height: 88rpx;
				text-align: center;
			}

			.agree {
				line-height: 88rpx;
				width: 340rpx;
				height: 88rpx;
				border-radius: 44rpx;
				font-size: 30rpx;
				font-weight: 500;
				background-color: rgba(204, 204, 203, 1.0);
				color: #fff;
				text-align: center;
			}
		}
	}
</style>
